package cn.zktr.Personnel.model.service.ouyangpeng;

import java.util.List;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.zktr.Personnel.model.dao.IntentionDAO;
import cn.zktr.Personnel.model.dao.ouyangpeng.RetDemDao;
import cn.zktr.Personnel.model.dao.ouyangpeng.RetRseDao;
import cn.zktr.Personnel.model.dao.ouyangpeng.RetWenDao;
import cn.zktr.Personnel.model.dao.tanyali.EmaFebDao;
import cn.zktr.Personnel.model.mappers.ouyangpng.PerRetRseMapper;
import cn.zktr.Personnel.model.pojos.PerEmaFeb;
import cn.zktr.Personnel.model.pojos.PerIntention;
import cn.zktr.Personnel.model.pojos.PerPmsAct;
import cn.zktr.Personnel.model.pojos.PerRetDem;
import cn.zktr.Personnel.model.pojos.PerRetRse;
import cn.zktr.Personnel.model.pojos.PerRetWAlt;
import cn.zktr.Personnel.model.pojos.PerRetWen;

/**
 * @author lenovo
 *初步审核
 */
@Service
@Transactional(rollbackOn=Exception.class)
public class RetDemService {
	@Autowired
	private RetDemDao retdemdao;
	@Autowired
	private RetRseDao retrsedao;
	@Autowired
	private IntentionDAO intendao;
	@Autowired
	private PerRetRseMapper rsemaper;
	@Autowired
	private EmaFebDao febdao;
	@Autowired
	private RetWenDao wendao;
	
	public Iterable<PerRetDem> selectDemAll(){
		return retdemdao.findAll();
		
	}
	//初步审核id
	public List<PerRetDem> updatedemid(Integer demid) {
		return rsemaper.updatedemid(demid);
	}
    //初步审核通过
    public void selectchubutg(Integer demsatat) {
    	PerRetDem rseids=retdemdao.findById(demsatat).get();
		rseids.setDemqld("1");
		retdemdao.save(rseids);
	}
    //通过初步审核时修改简历状态
    public void tgchubujianli(Integer rsestat) {
    	PerRetRse rseids=retrsedao.findById(rsestat).get();
    	rseids.setRsestat("1");
    	retrsedao.save(rseids);
    }
    //初步审核不通过
    public void selectchububutg(Integer demsatat) {
    	PerRetDem rseids=retdemdao.findById(demsatat).get();
		rseids.setDemqld("2");
		retdemdao.save(rseids);
	}
    //初步审核不通过时修改简历状态
    public void butgchubujianli(Integer rsestat) {
    	PerRetRse rseids=retrsedao.findById(rsestat).get();
    	rseids.setRsestat("2");
    	retrsedao.save(rseids);
    }
    //发起考试--->意向表添加记录
    public void yixiangxz(PerIntention inten) {
    	intendao.save(inten);
    	List<PerIntention> intent = (List<PerIntention>) intendao.findAll();
    	//向信息反馈表添加数据
    	PerEmaFeb feb=new PerEmaFeb();
    	feb.setPerIntention(intent.get(intent.size()-1));
    	feb.setFebstat("1");
    	febdao.save(feb);
    }
    //初步审核表发起考试
    public void kaoschububutg(Integer demsatat) {
    	PerRetDem rseids=retdemdao.findById(demsatat).get();
		rseids.setDemqld("3");
		retdemdao.save(rseids);
	}
    //发起考试时简历状态
    public void kschubujianli(Integer rsestat) {
    	PerRetRse rseids=retrsedao.findById(rsestat).get();
    	rseids.setRsestat("3");
    	retrsedao.save(rseids);
    }
    //发起考试时新增笔试记录
    public void kaosbihsi(PerRetWen wen) {
    	wendao.save(wen);
    }
}
